Optimization of Meta-Template Instantiations

ABSTRACT

An illustrative embodiment provides a computer-implemented method for an alternate type system for optimizing the evaluation and use of meta-template instantiations. The computer-implemented method obtains a source code, instantiates an element of the source code to form an instantiated element and identifies a meta-template within the instantiated element to form an identified meta-template. The computer-implemented method creates an entry for the identified meta-template in a first data structure, wherein the entry comprises a set of mapped entries, creates an associated entry in a second data structure linked to the entry comprising the set of mapped entries, wherein the associated entry represents the set of mapped entries, and uses the associated entry of the second data structure in combination with the entry of the first data structure.

CROSS-REFERENCE TO RELATED APPLICATIONS

The present application is a continuation of U.S. patent applicationSer. No. 14/556,271 filed on Dec. 1, 2014, which is a continuation ofU.S. patent application Ser. No. 12/894,642 filed on Sep. 30, 2010, nowU.S. Pat. No. 8,904,370.

FIELD OF THE INVENTION

This disclosure relates generally to programming language optimizationin a data processing system and more specifically to an alternate typesystem for optimizing the evaluation of meta-template instantiations inprogramming compilations.

BACKGROUND

Within the C++ programming language, programmers have created afunctional programming language using various implementations of thetemplate and the type system. Current compiler implementations allowprogrammers to program complex problems using template instantiations,which enable aspects of the problems to be solved at compile time ratherthan at run time. However, the type system of the compiler is notdesigned to handle the large number of template instantiations and typescreated while computing the results. As use of the type system increasesthe performance of the compiler degrades.

For example, in the following code snippet, the template class Fib<20>will create Fib<19> and Fib<18>. This progressive instantiationcontinues until the specializations Fib<l> and Fib<O> are used. Thespecializations provide termination of the recursive process.

template <int N>

struct Fib {

enum E {Result=Fib<N-1>::Result+Fib<N-2>::Result};

};

template <> struct Fib<O> {enum{Result=0};1;

template <> struct Fib<l> {enum{Result=0};};

int x=Fib<20>::Result;

Although the user only used Fib<20>, other instantiations were requiredto compute the result. In this case the number of extra instantiationsgrows linearly with the value of the template argument. Use of Fib<21>will only require one more instantiation than Fib<20>.

As program complexity increases, so does the recursion thereby causingan overload of the regular type system. As the regular type system ofthe compiler becomes overloaded the compilation time increases due tothe number of and size of entries to be processed as well as the timerequired for performing the compilations.

SUMMARY

According to one embodiment, a computer-implemented method for analternate type system for optimizing the evaluation and use ofmeta-template instantiations obtains a source code, instantiates anelement of the source code to form an instantiated element, identifies ameta-template within the instantiated element to form an identifiedmeta-template, creates an entry for the identified meta-template in afirst data structure, wherein the entry comprises a set of mappedentries, creates an associated entry in a second data structure linkedto the entry comprising the set of mapped entries, wherein theassociated entry represents the set of mapped entries, and uses theassociated entry of the second data structure in combination with theentry of the first data structure.

According to another embodiment, a computer program product for analternate type system for optimizing the evaluation and use ofmeta-template instantiations is presented. The computer program productcomprises a computer recordable medium containing computer executableprogram code stored thereon, the computer executable program codecomprising, computer executable program code for obtaining a sourcecode, computer executable program code for instantiating an element ofthe source code to form an instantiated element, computer executableprogram code for identifying a meta-template within the instantiatedelement to form an identified meta-template, computer executable programcode for creating an entry for the identified meta-template in a firstdata structure, wherein the entry comprises a set of mapped entries,computer executable program code for creating an associated entry in asecond data structure linked to the entry comprising the set of mappedentries, wherein the associated entry represents the set of mappedentries, and computer executable program code for using the associatedentry of the second data structure in combination with the entry of thefirst data structure.

According to another embodiment, an apparatus for an alternate typesystem for optimizing the evaluation and use of meta-templateinstantiations is presented. The apparatus comprises a communicationsfabric, a memory connected to the communications fabric, wherein thememory contains computer executable program code, a communications unitconnected to the communications fabric, an input/output unit connectedto the communications fabric, a display connected to the communicationsfabric, and a processor unit connected to the communications fabric,wherein the processor unit executes the computer executable program codeto direct the apparatus to obtain a source code, instantiate an elementof the source code to form an instantiated element, identify ameta-template within the instantiated element to form an identifiedmeta-template, create an entry for the identified meta-template in afirst data structure, wherein the entry comprises a set of mappedentries, create an associated entry in a second data structure linked tothe entry comprising the set of mapped entries, wherein the associatedentry represents the set of mapped entries, and use the associated entryof the second data structure in combination with the entry of the firstdata structure.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS

For a more complete understanding of this disclosure, reference is nowmade to the following brief description, taken in conjunction with theaccompanying drawings and detailed description, wherein like referencenumerals represent like parts.

FIG. 1 is a block diagram of a data processing system environment thatmay be operable for various embodiments of the disclosure;

FIG. 2 is a block diagram of high level components of a compiler, inaccordance with various embodiments of the disclosure;

FIG. 3 is a flowchart of a high level process using the compiler of FIG.2 in accordance with one embodiment of the disclosure;

FIGS. 4 is a flowchart of a process for identifying a meta-templateinstantiation of FIG. 3 in accordance with one embodiment of thedisclosure;

FIG. 5 (FIG. 5A and FIG. 5B) is a flowchart of a portion of atransformation process of FIG. 4 according to one embodiment of thedisclosure; and

FIG. 6 (FIG. 6A and FIG. 6B) is a flowchart of a process of handlingstatic member functions according to one embodiment of the disclosure.

DETAILED DESCRIPTION

Although an illustrative implementation of one or more embodiments isprovided below, the disclosed systems and/or methods may be implementedusing any number of techniques. This disclosure should in no way belimited to the illustrative implementations, drawings, and techniquesillustrated below, including the exemplary designs and implementationsillustrated and described herein, but may be modified within the scopeof the appended claims along with their full scope of equivalents.

As will be appreciated by one skilled in the art, the present disclosuremay be embodied as a system, method or computer program product.Accordingly, the present disclosure may take the form of an entirelyhardware embodiment, an entirely software embodiment (includingfirmware, resident software, micro-code, etc.) fixed in a tangiblestorage medium, or an embodiment combining software and hardware aspectsthat may all generally be referred to herein as a “circuit,” “module,”or “system.” Furthermore, the present invention may take the form of acomputer program product tangibly embodied in any storage medium withcomputer usable program code embodied in the medium.

Computer program code for carrying out operations of the presentdisclosure may be written in any combination of one or more programminglanguages, including an object oriented programming language such asJava™, Smalltalk, C++, or the like and conventional proceduralprogramming languages, such as the “C” programming language or similarprogramming languages. Java and all Java-based trademarks and logos aretrademarks of Sun Microsystems, Inc., in the United States, othercountries or both. The program code may execute entirely on the user'scomputer, partly on the user's computer, as a stand-alone softwarepackage, partly on the user's computer and partly on a remote computeror entirely on the remote computer or server. In the latter scenario,the remote computer may be connected to the user's computer through anytype of network, including a local area network (LAN) or a wide areanetwork (WAN), or the connection may be made to an external computer(for example, through the Internet using an Internet Service Provider).

The present disclosure is described below with reference to flowchartillustrations and/or block diagrams of methods, apparatus, systems, andcomputer program products according to embodiments of the invention. Itwill be understood that each block of the flowchart illustrations and/orblock diagrams, and combinations of blocks in the flowchartillustrations and/or block diagrams, can be implemented by computerprogram instructions.

These computer program instructions may be provided to a processor of ageneral purpose computer, special purpose computer, or otherprogrammable data processing apparatus to produce a machine, such thatthe instructions, which execute via the processor of the computer orother programmable data processing apparatus, create means forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks. These computer program instructions may also bestored in a computer readable medium that can direct a computer or otherprogrammable data processing apparatus to function in a particularmanner, such that the instructions stored in the computer readablemedium produce an article of manufacture including instruction meanswhich implement the function/act specified in the flowchart and/or blockdiagram block or blocks.

The computer program instructions may also be loaded onto a computer orother programmable data processing apparatus to cause a series ofoperational steps to be performed on the computer or other programmableapparatus to produce a computer-implemented process such that theinstructions which execute on the computer or other programmableapparatus provide processes for implementing the functions/actsspecified in the flowchart and/or block diagram block or blocks.

Turning now to FIG. 1, a block diagram of an exemplary data processingsystem environment that may be operable for various embodiments of thedisclosure is presented. In this illustrative example, data processingsystem 100 includes communications fabric 102, which providescommunications between processor unit 104, memory 106, persistentstorage 108, communications unit 110, input/output (I/O) unit 112, anddisplay 114.

Processor unit 104 serves to execute instructions for software that maybe loaded into memory 106. Processor unit 104 may be a set of one ormore processors or may be a multiprocessor core, depending on theparticular implementation. Further, processor unit 104 may beimplemented using one or more heterogeneous processor systems in which amain processor is present with secondary processors on a single chip. Asanother illustrative example, processor unit 104 may be a symmetricmulti-processor system containing multiple processors of the same type.

Memory 106 and persistent storage 108 are examples of storage devices116. A storage device is any piece of hardware that is capable ofstoring information, such as, for example without limitation, data,program code in functional form, and/or other suitable informationeither on a temporary basis and/or a permanent basis. Memory 106, inthese examples, may be, for example, a random access memory or any othersuitable volatile or non-volatile storage device. Persistent storage 108may take various forms depending on the particular implementation. Forexample, persistent storage 108 may contain one or more components ordevices. For example, persistent storage 108 may be a hard drive, aflash memory, a rewritable optical disk, a rewritable magnetic tape, orsome combination of the above. The media used by persistent storage 108also may be removable. For example, a removable hard drive may be usedfor persistent storage 108.

Communications unit 110, in these examples, provides for communicationswith other data processing systems or devices. In these examples,communications unit 110 is a network interface card. Communications unit110 may provide communications through the use of either or bothphysical and wireless communications links

Input/output unit 112 allows for input and output of data with otherdevices that may be connected to data processing system 100. Forexample, input/output unit 112 may provide a connection for user inputthrough a keyboard, a mouse, and/or some other suitable input device.Further, input/output unit 112 may send output to a printer. Display 114provides a mechanism to display information to a user.

Instructions for the operating system, applications and/or programs maybe located in storage devices 116, which are in communication withprocessor unit 104 through communications fabric 102. In theseillustrative examples the instructions are in a functional form onpersistent storage 108. These instructions may be loaded into memory 106for execution by processor unit 104. The processes of the differentembodiments may be performed by processor unit 104 usingcomputer-implemented instructions, which may be located in a memory,such as memory 106.

These instructions are referred to as program code, computer usableprogram code, or computer readable program code that may be read andexecuted by a processor in processor unit 104. The program code in thedifferent embodiments may be embodied on different physical or tangiblecomputer readable media, such as memory 106 or persistent storage 108.

Program code 118 is located in a functional form on computer readablemedia 120 that is selectively removable and may be loaded onto ortransferred to data processing system 100 for execution by processorunit 104. Program code 118 and computer readable media 120 form computerprogram product 122 in these examples. In one example, computer readablemedia 120 may be in a tangible form, such as, for example, an optical ormagnetic disc that is inserted or placed into a drive or other devicethat is part of persistent storage 108 for transfer onto a storagedevice, such as a hard drive that is part of persistent storage 108. Ina tangible form, computer readable media 120 also may take the form of apersistent storage, such as a hard drive, a thumb drive, or a flashmemory that is connected to data processing system 100. The tangibleform of computer readable media 120 is also referred to as computerrecordable storage media. In some instances, computer readable media 120may not be removable.

In some illustrative embodiments, program code 118 may be downloadedover a network to persistent storage 108 from another device or dataprocessing system for use within data processing system 100. Forinstance, program code stored in a computer readable storage medium in aserver data processing system may be downloaded over a network from theserver to data processing system 100. The data processing systemproviding program code 118 may be a server computer, a client computer,or some other device capable of storing and transmitting program code118.

The different components illustrated for data processing system 100 arenot meant to provide architectural limitations to the manner in whichdifferent embodiments may be implemented. The different illustrativeembodiments may be implemented in a data processing system includingcomponents in addition to or in place of those illustrated for dataprocessing system 100. Other components shown in FIG. 1 can be variedfrom the illustrative examples shown. The different embodiments may beimplemented using any hardware device or system capable of executingprogram code. As one example, the data processing system may includeorganic components integrated with inorganic components and/or may becomprised entirely of organic components excluding a human being. Forexample, a storage device may be comprised of an organic semiconductor.

As another example, a storage device in data processing system 100 maybe any hardware apparatus that may store data. Memory 106, persistentstorage 108 and computer readable media 120 are examples of storagedevices in a tangible form.

In another example, a bus system may be used to implement communicationsfabric 102 and may be comprised of one or more buses, such as a systembus or an input/output bus. Of course, the bus system may be implementedusing any suitable type of architecture that provides for a transfer ofdata between different components or devices attached to the bus system.Additionally, a communications unit may include one or more devices usedto transmit and receive data, such as a modem or a network adapter.Further, a memory may be, for example, memory 106 or a cache such asfound in an interface and memory controller hub that may be present incommunications fabric 102.

Illustrative embodiments thus provide examples of identifyingmeta-templates within instantiated source code elements. Dependentfunctions instantiated from the meta-template are mapped into analternate type system. Each entry in the alternate type system issmaller than a similar entry in a regular type system. The use of thealternate type system typically allows the compiler to perform moreefficiently than when using the regular type system without thealternate type system.

Using data processing system 100 of FIG. 1 as an example, anillustrative embodiment provides a computer-implemented method for analternate type system for optimizing the evaluation and use ofmeta-template instantiations. The computer-implemented method usingprocessor unit 104 to obtain a source code from storage devices 116through communications fabric 102, instantiates an element of the sourcecode to form an instantiated element and identifies a meta-templatewithin the instantiated element to form an identified meta-template. Thecomputer-implemented method creates an entry for the identifiedmeta-template in a first data structure, which may reside in memory 106or persistent storage 108, wherein the entry comprises a set of mappedentries, creates an associated entry in a second data structure, whichalso may reside in memory 106 or persistent storage 108, linked to theset of mapped entries, wherein the associated entry represents the setof mapped entries; and uses the associated entry of the second datastructure in combination with the entry of the first data structure. Thecomputer-implemented method thus provides an alternate type system ofthe first data structure to optimize use of meta-template instantiationsin programming compilations. The computer-implemented method may bestored in storage devices 116 until used or installed as program code118 from computer readable media 120 in the form of program product 122.

With reference to FIG. 2, a block diagram of high-level components of acompiler, in accordance with various embodiments of the disclosure ispresented. Compiler 200 comprises a number of components for thecompilation of source code 202 into compiled code 204. Components ofcompiler 200 include, but are not limited to, instantiation process 206,template analyzer 208, regular type system 210, template mapper 212 andalternate type system 214.

Source code 202 may contain various templates embedded within a set ofinstructions. Source code 202 is provided as input for parsing tocompiler 200. In conjunction with parsing, instantiation process 206determines whether a template is located within the source code beingprocessed. When a determination is made that a template of some form ispresent, template analyzer 208 determines whether the template is of aform known as a meta-template.

When the template, as determined by template analyzer 208, is not ameta-template, the template is processed to generate the requiredentries associated with the template into regular type system 210. Whenthe template as determined by template analyzer 208 is a meta-template,template mapper 212 further processes the meta-template to evaluate themeta-template by creating a set of entries in a first data structurecomprising an alternate type system 214. The set of entries for themeta-template, comprising one or more entries, stored in alternate typesystem 214, are smaller in size than associated entries created for asecond data structure of a regular type system 210. The smaller size ofeach entry, contained within, allow alternate type system 214 totypically be more efficient and responsive than regular type system 210.Alternate type system 214 therefore provides a compact type system andincludes a link from the set of entries for the meta-template to regulartype system 210. The reduced size of each entry in alternate type system214 enables efficient processing in conjunction with regular type system210 and thus provides an optimization of the evaluation and use of themeta-template when compared to an implementation with only the use ofregular type system 210.

For example, a set of entries for a meta-template may have five entriesin alternate type system 214. The five entries are dependent entriesused within the context of the identified meta-template. There is onelink from the set of five entries of the meta-template to an associatedentry in regular type system 210. Regular type system 210, inillustrative embodiments, does not include the dependent entries, asmaintained in a compact form, of the alternate type system 214. Theregular type system, in illustrative embodiments, therefore does notexpand as rapidly as in previous implementations.

With reference to FIG. 3 a flowchart of a high-level process using thecompiler of FIG. 2 in accordance with one embodiment of the disclosureis presented. Process 300 is an example of using compiler 200 of FIG. 2in a C++ programming environment. A meta-template can be recognizedwithin source code 202 by compiler 200 of FIG. 2. A meta-template is atemplate that has no data members and therefore contains only enums orstatic data members and only static member functions. A meta-templatetypically has one or more of constant static data members, enums,typedefs and static member functions, for example, class scopeconstants.

A user typically instantiates one meta-template to get an answer whilethe compiler needs to instantiate a large number of other meta-templatesto compute the answer. All of the instantiations take place in regulartype system 210 that compiler 200 of FIG. 2 uses for user declaredtypes. The many instantiations in regular type system 210 bloat the typesystem and slow down compilation. Another effect of the previousimplementations is to constrain the size of problems that can be solvedusing meta-templates. The ability to resolve problems is thereforelimited by the size of and time that is required to use regular typesystem 210 of FIG. 2.

In the illustrative embodiment of FIG. 3 process 300 starts (step 302)and obtains a source code, such as source code 202 of FIG. 2 (step 304).Instantiation of source code elements is performed (step 306). As eachsource code element is instantiated an identification of templateswithin the source code is performed (step 308). The identificationoperation of process 300 determines whether there are templates andwhether the identified templates are meta-templates. Each instantiationof the identified meta-templates is placed in a separate entry ofalternate type system 214 of compiler 200 of FIG. 2. The alternate typesystem will be smaller and faster than the regular type system. Thecompiler can use the alternate type system for a template if a set ofpredefined conditions is met: A first condition requires the template tobe a meta-template. A second condition requires the template to have oneor more explicit (or partial) specializations. The specializations actas terminating conditions that will stop the recursive templateinstantiations associated with the processing of the meta-template.

Having identified a template as a meta-template in step 308, process 300creates for each of these templates a mapping to map the C++datastructure into a small data structure, within the compiler (step 310).When the meta-template is evaluated other instantiations may berequired. The recursive behaviour of meta-templates, for example where afunction Fib<20> instantiates function Fib<19> and function Fib<18>, andother functions in sequence, will create a graph in the alternate typesystem that is used to evaluate the result of the instantiation done bythe program. Each node in the graph represents one instantiation. Eachnode contains the values assigned to static data members, and enums andtypedefs to non-meta-template types. The edges between the nodesrepresent the typedefs to other meta-templates.

When the compiler encounters an instantiation for a template within theuser code that satisfies the criteria for a meta-template, compiler 200of FIG. 2 will first create a mapping for the instantiation in themeta-template instantiation graph, alternate type system 214 of FIG. 2.That mapping will then be used to create an associated entry in regulartype system 210 of FIG. 2 representing the instantiation associated withthe meta-template (step 312). The associated entry contains the resultsof the evaluation. Regular type system 210 of FIG. 2 then only increasesby one entry instead of the large number of entries required to computethe results for the instantiation associated with the meta-template. Theset of entries, in the alternate type system, from the source code isprocessed to resolve the problem (step 314) with process 300 terminatingthereafter (step 316).

Static member functions for meta-templates are also handled specially tominimize the number of instantiations that are generated. Typically astatic member function will use some of the instantiations only found inthe alternate type system. The source code of a static member functionneeds to be transformed so the instantiations that were only created inalternate type system 214 of FIG. 2 are replaced with the results. Thisis done by generating the code for the static member functions of themeta-template instantiations that are actually used by the differentmechanisms of process 300 rather than a process for regular functions.

With reference to FIG. 4 a flowchart of a process for identifying ameta-template instantiation of FIG. 3 in accordance with one embodimentof the disclosure is presented. Process 400 is an example of theidentification process used in step 308 of process 300 of FIG. 3.

Process 400 begins (step 402) and determines whether the reference is astatic member function within the identified meta-template to form anidentified static member function (step 404). When a determination ismade that the reference is a static member function within theidentified meta-template, a “yes” result is obtained. When adetermination is made that the reference is not a static member functionwithin the identified meta-template, a “no” result is obtained. When a“no” result is obtained in step 404, process 400 skips to step 410. Whena “yes” is obtained in step 404, process 400 determines whether theidentified static member function is a member of a dependentmeta-template instantiation (step 406). Identifiers used within thestatic member function can be categorized as either references tomembers of dependent meta-template instantiations or references tomembers of non-dependent meta-template instantiations.

When a determination is made that the identified static member functionis a member of a dependent meta-template instantiation, a “yes” resultis obtained. When a determination is made that the identified staticmember function is not a member of a dependent meta-templateinstantiation, a “no” result is obtained. When a “yes” result isobtained in step 406, the dependent meta-template instantiations aretransformed to use an alternate type system (step 408) with process 400terminating thereafter (step 412). The transformation ensures theidentifiers used in the static member function that use instantiationsonly instantiated in the alternate type system do not create aninstantiation in the regular type system.

When a “no” result is obtained in step 406, the identified static memberfunction is a member of a non-dependent meta-template instantiation; andprocess 400 generates the nondependent meta-template instantiations as aregular function in the regular type system (step 410), with process 400terminating thereafter (step 412).

With reference to FIG. 5, a flowchart of a portion of a transformationprocess of FIG. 4 according to one embodiment of the disclosure ispresented. Process 500 is an example of replacing a reference of thetransformation process of step 408 of process 400 of FIG. 4. The usercode in the static member functions, provided as input to process 500,may contain references to meta-templates (including members and templatearguments). The replacement performed in process 500 is designed toeliminate references in the function body that are not defined in theregular type system. Thus process 500 provides a capability to processstatic member functions and replace references to elements in thealternate type system with values or types from the regular type system.

Process 500 starts (step 502) and locates a first name used in the bodyof the static member function to form a located name (step 504). Process500 determines whether the located name is qualified (step 506). When adetermination is made that the name is qualified, a “yes” result isobtained. When a determination is made that the located name is notqualified, a “no” response is obtained.

When a “no” is obtained in step 506, a determination is made whether thelocated name represents a meta-template instantiation, a member of themeta-template or an argument to the meta-template (step 508). When adetermination is made that the located name represents a meta-templateinstantiation, a member of the meta-template or a template argument, a“yes” result is obtained in step 508. When a “yes” result is obtained instep 508, process 500 replaces the located name with a result stored inthe alternate type system (step 512), and process 500 proceeds to step516. When a determination is made that the located name does notrepresent a meta-template instantiation, a member of the meta-templateor an argument to the meta-template, a “no” result is obtained in step508. When a “no” result is obtained in step 508, no replacement is doneand process 500 skips to step 516.

When a “yes” is obtained in step 506, a determination is made whetherleading qualifiers of the located name represent a meta-templateinstantiation, a member of the meta-template or an argument to themeta-template (step 510). When a determination is made that the leadingqualifiers of the located name represent a meta-template instantiation,a member of the meta-template or an argument to the meta-template, a“yes” result is obtained in step 510. When a determination is made thatleading qualifiers of the located name do not represent a meta-templateinstantiation, a member of the meta-template or an argument to themeta-template a “no” result is obtained in step 510. When a “no” resultis obtained in step 510, no replacement is done and process 500 skips tostep 516.

When a “yes” result is obtained in step 510, process 500 replaces theleading qualifiers of the located name with a corresponding resultstored in the alternate type system (step 514). The replacement of theleading qualifiers transforms the qualified name to only use theidentifiers and types available in the regular type system.

Process 500 then determines whether more names exist (step 516). When adetermination is made that more names exist, “yes” result is obtained.When a determination is made that no more names exist, “no” result isobtained. When a “no” result is obtained, and process 500 terminates(step 520). When a “yes” result is obtained, process 500 locates a nextname (step 518), with process 500 looping back to step 506.

With reference to FIG. 6 a flowchart of a process of handling staticmember functions according to one embodiment of the disclosure ispresented. Process 600 is an example of a portion of transformation step408 of process 400 of FIG. 4.

Process 600 starts (step 602) and identifies an enum or a static datamember to form an identified enum or an identified static data member(step 604). Process 600 replaces the reference for the identified enumor the reference for the identified static data member with a value forthe identified enum or another value for the identified static datamember (step 606). A determination is made as to whether a typedef isnot part of a scope chain that ends in a reference to the identifiedenum or the identified static data member function (step 608).

When a determination is made that the typedef is part of a scope chainthat ends in a reference to the identified enum or the identified staticdata member function a “yes” result is obtained. When a determination ismade that the typedef is not part of a scope chain that ends in areference to the identified enum or the identified static data memberfunction a “no” result is obtained. Responsive to a “no” result in step608 that represents a determination that the typedef is not part of ascope chain that ends in the reference to the identified enum or theidentified static data member, process 600 adds the type of the lasttypedef in the scope chain to the regular type system (step 610).Responsive receiving a “yes” in step 608, process 600 terminates (step620).

Following step 612, a determination is made whether the identifiedstatic member function is a call to a dependent meta-template memberfunction is performed (step 614). When a determination is made that theidentified static member function is a call to the dependentmeta-template member function, a “yes” result is obtained. When adetermination is made that the identified static member function is nota call to the dependent meta-template member function, a “no” result isobtained.

Responsive to the identified static member function being a call to adependent meta-template member function, obtaining a “yes” result instep 612; Process 600 generates code for the static member function toform generated code (step 616). Process 600 places the generated codeinline (step 618), terminating thereafter (step 620). When the referenceto the static member function takes the address of the static memberfunction then the static member function has to be generated just asthough the user instantiated the template. When a “no” result isobtained in step 614, process 600 terminates thereafter (step 620).

Illustrative embodiments thus provide examples of identifyingmeta-templates within instantiated source code elements. Dependentfunctions instantiated from the meta-template are mapped into analternate type system. Each entry in the alternate type system issmaller than a similar entry in a regular type system, however eachentry represents a collection of entries that would have otherwise beenmade in the regular type system.

An illustrative embodiment provides a computer-implemented method for analternate type system for optimizing evaluation and use of meta-templateinstantiations. The computer-implemented method obtains a source code,instantiates an element of the source code to form an instantiatedelement and identifies a meta-template within the instantiated elementto form an identified meta-template. The computer-implemented methodcreates an entry for the identified meta-template in a first datastructure, wherein the entry comprises a set of mapped entries; createsan associated entry in a second data structure, a regular type system,linked to the set of mapped entries, wherein the associated entryrepresents the set of mapped entries; and uses the associated entry ofthe second data structure in combination with the entry of the firstdata structure. The computer-implemented method thus provides analternate type system in the form of a first data structure to optimizeevaluation and use of meta-template instantiations in programcompilations.

The flowchart and block diagrams in the figures illustrate thearchitecture, functionality, and operation of possible implementationsof systems, methods, and computer program products according to variousembodiments of the present invention. In this regard, each block in theflowchart or block diagrams may represent a module, segment, or portionof code, which comprises one or more executable instructions forimplementing a specified logical function. It should also be noted that,in some alternative implementations, the functions noted in the blockmight occur out of the order noted in the figures. For example, twoblocks shown in succession may, in fact, be executed substantiallyconcurrently, or the blocks may sometimes be executed in the reverseorder, depending upon the functionality involved. It will also be notedthat each block of the block diagrams and/or flowchart illustration, andcombinations of blocks in the block diagrams and/or flowchartillustration, can be implemented by special purpose hardware-basedsystems that perform the specified functions or acts, or combinations ofspecial purpose hardware and computer instructions.

The corresponding structures, materials, acts, and equivalents of allmeans or step plus function elements in the claims below are intended toinclude any structure, material, or act for performing the function incombination with other claimed elements as specifically claimed. Thedescription of the present invention has been presented for purposes ofillustration and description, but is not intended to be exhaustive orlimited to the invention in the form disclosed. Many modifications andvariations will be apparent to those of ordinary skill in the artwithout departing from the scope and spirit of the invention. Theembodiment was chosen and described in order to best explain theprinciples of the invention and the practical application, and to enableothers of ordinary skill in the art to understand the invention forvarious embodiments with various modifications as are suited to theparticular use contemplated.

The invention can take the form of an entirely hardware embodiment, anentirely software embodiment or an embodiment containing both hardwareand software elements. In a preferred embodiment, the invention isimplemented in software, which includes but is not limited to firmware,resident software, microcode, and other software media that may berecognized by one skilled in the art.

It is important to note that while the present invention has beendescribed in the context of a fully functioning data processing system,those of ordinary skill in the art will appreciate that the processes ofthe present invention are capable of being distributed in the form of acomputer readable medium of instructions. Examples of computer readablemedia include recordable-type media, such as a floppy disk, a hard diskdrive, a RAM, CD-ROMs, and DVDROMs. The computer readable media may takethe form of coded formats that are decoded for actual use in aparticular data processing system.

A data processing system suitable for storing and/or executing programcode will include at least one processor coupled directly or indirectlyto memory elements through a system bus. The memory elements can includelocal memory employed during actual execution of the program code, bulkstorage, and cache memories which provide temporary storage of at leastsome program code in order to reduce the number of times code must beretrieved from bulk storage during execution.

Input/output or I/O devices (including but not limited to keyboards,displays, pointing devices, etc.) can be coupled to the system eitherdirectly or through intervening I/O controllers.

Network adapters may also be coupled to the system to enable the dataprocessing system to become coupled to other data processing systems orremote printers or storage devices through intervening private or publicnetworks. Modems, cable modems, and Ethernet cards are just a few of thecurrently available types of network adapters.

What is claimed is:
 1. A computer program product comprising: a computerreadable storage medium; and computer usable code stored on the computerreadable storage medium, where, when executed by a processor, thecomputer usable code causes a computer to: determine that a template ina source code is a meta-template and a template in the source code is ina form other than the meta-template; create a set of entries in a firstdata structure of an alternate type system for the meta-template,wherein each entry of the set of entries is to correspond to a separaterecursive instantiation; and conduct an evaluation of the set of entriesin the first data structure of the alternate type system to generate asingle entry in a second data structure of a regular type system that isto be utilized to resolve a problem, wherein the single entry is tocorrespond to a result of the evaluation, and wherein the second datastructure of the regular type system is to include an entry that is tobe generated independent of the evaluation for the template in the formother than the meta-template.
 2. The computer program product of claim1, wherein, when executed by a processor, the computer usable codecauses a computer to instantiate the source code to identify anytemplate in the source code.
 3. The computer program product of claim 1,wherein, when executed by a processor, the computer usable code causes acomputer to provide a link from the set of entries in the first datastructure of the alternate type system to map the set of entries to thesingle entry in the second data structure of the regular type system. 4.A method comprising: determining that a template in a source code is ameta-template and a template in the source code is in a form other thanthe meta-template; creating a set of entries in a first data structureof an alternate type system for the meta-template, wherein each entry ofthe set of entries corresponds to a separate recursive instantiation;and conducting an evaluation of the set of entries in the first datastructure of the alternate type system to generate a single entry in asecond data structure of a regular type system that is utilized toresolve a problem, wherein the single entry corresponds to a result ofthe evaluation, and wherein the second data structure of the regulartype system includes an entry that is generated independent of theevaluation for the template in the form other than the meta-template. 5.The method of claim 4, further including instantiating the source codeto identify any template in the source code.
 6. The method of claim 4,further including providing a link from the set of entries in the firstdata structure of the alternate type system to map the set of entries tothe single entry in the second data structure of the regular typesystem.
 7. An apparatus comprising: a template analyzer to determinethat a template in a source code is a meta-template and a template inthe source code is in a form other than the meta-template; a templatemapper to: create a set of entries in a first data structure of analternate type system for the meta-template, wherein each entry of theset of entries is to correspond to a separate recursive instantiation;and conduct an evaluation of the set of entries in the first datastructure of the alternate type system to generate a single entry in asecond data structure of a regular type system that is to be utilized toresolve a problem, wherein the single entry is to correspond to a resultof the evaluation, and wherein the second data structure of the regulartype system is to include an entry that is to be generated independentof the evaluation for the template in the form other than themeta-template.
 8. The apparatus of claim 7, further including thetemplate analyzer to instantiate the source code to identify anytemplate in the source code.
 9. The apparatus of claim 7, furtherincluding the template mapper to provide a link from the set of entriesin the first data structure of the alternate type system to map the setof entries to the single entry in the second data structure of theregular type system.